<div class="breadcrumbs" id="breadcrumbs">
    <script type="text/javascript">
        try {
            ace.settings.check('breadcrumbs', 'fixed')
        } catch (e) {
        }
    </script>
    <!-- /.breadcrumb -->

    <div class="nav-search" id="nav-search">
        <form class="form-search">
								<span class="input-icon">
									<input type="text" placeholder="Search ..." class="nav-search-input"
                                           id="nav-search-input" autocomplete="off"/>
									<i class="ace-icon fa fa-search nav-search-icon"></i>
								</span>
        </form>
    </div>
    <!-- /.nav-search -->
</div>

<div class="page-content">
    <div class="page-header">
        <h1>
            风险管理
            <small>
                <i class="ace-icon fa fa-angle-double-right"></i>
                按风险点上传
            </small>
        </h1>
    </div>
    <!-- /.page-header -->
    <div class="row">
        <div class="col-xs-12">
            <div class="scrollspy-example">
                <div class="clearfix">
                    <div class="pull-right tableTools-container"></div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="form-field-1">文件日期 </label>

                    <div class="col-sm-9">
                        <div class="input-group col-xs-10 col-sm-5">
                            <input class="form-control date-picker" id="uploadDate" type="text"
                                   data-date-format="yyyy-mm" />
                                            <span class="input-group-addon">
                                                <i class="fa fa-calendar bigger-110"></i>
                                            </span>
                        </div>
                    </div>
                </div>
                <div>
                    <table id="dynamic-table" class="table table-striped table-bordered table-hover">
                        <thead>
                        <tr>
                            <th>风险点ID</th>
                            <th>风险点名称</th>
                            <th>上传</th>
                            <th>文件名</th>
                            <th>上传状态</th>
                        </tr>
                        </thead>

                        <tbody>
                    <#list fxLst as lst>
                        <tr>
                            <td>${lst.id!}</td>
                            <td>
                                <a href="#">${lst.fxdmc!}</a>
                            </td>
                            <td><input class="upload-select" type="file" name="uploadify" id="${lst.id!}" /></td>
                            <td><span id="${lst.id!}_name" style="float:left"></span></td>
                            <td>
                                <div class="hidden-sm hidden-xs action-buttons">
                                    <span class="red" id="${lst.id!}_status">未上传</span>
                                </div>

                            </td>
                        </tr>
                    </#list>
                        </tbody>
                    </table>

            </div>
        </div>
        <!-- /.col -->
    </div>
    <!-- /.row -->
</div>
<script>
    $(function () {
        $('.date-picker').datepicker({
            autoclose: true,
            todayHighlight: true,
            language: 'zh-CN',
            dateFormat: 'yy-mm'
        }).next().on(ace.click_event, function () {
            $(this).prev().focus();
        });

        $(".upload-select").each(function () {
            var $this = $(this);

            $this.uploadify({
                'swf': $.router.uploadSwf,
                'uploader': '${basePath}encl/uploadSJ',
                'queueID': 'fileQueue',
                'fileObjName': 'uploadFile',
                'auto': true,
                'multi': false,
                'buttonCursor': 'hand',
                'dataType': 'json',
                'buttonText': '上传',
                'buttonImage': $.router.staticPath+"assets/images/upload_bg.png",
                'formData': {'fileId': $this.attr("id"), 'hcsj': $("#uploadDate").val()},
                'height': '25',
                'progressData': 'percentage',
                'fileTypeDesc': '支持格式:xls/xlsx',
                'fileTypeExts': '*.xls;*.xlsx',//允许的格式
                onUploadStart: function (file) {
                    $this.uploadify('settings', 'formData', {
                        'fileId': $this.attr("id"),
                        'hcsj': $("#uploadDate").val()
                    });
                },
                onUploadSuccess: function (file, data, response) {
                    var rs = JSON.parse(data);
                    if (rs.success) {
                        var name = $("#"+$this.attr("id")+"_name");
                        var status = $("#"+$this.attr("id")+"_status");
                        name.html(file.name);
                        status.removeClass("red");
                        status.addClass("green");
                        status.html('上传成功');

                        alert("文件:" + file.name + "上传成功!");
                    } else {
                        alert("文件:" + file.name + "上传失败!" + rs.message);
                    }
                },
                onError: function (event, queueID, fileObj) {//当单个文件上传出错时触发
                    alert("文件:" + fileObj.name + "上传失败");
                }

            });
        });
    });
</script>
<!-- page specific plugin scripts -->

<!--[if lte IE 8]>
<script src="assets/js/excanvas.min.js"></script>
<![endif]-->
<script src="assets/js/bootstrap-datepicker.min.js"></script>



